package Controller;

import java.awt.event.ActionEvent;
import Viewer.ExitView;
import Viewer.NotificationToController;

/**
 * exit del canzoniere
 * 
 * 
 * @author Andrea
 *
 */
public class ExitController extends AbstractController {

	/** Lista dei menu attivi. */
	//private List<DescriptorClass> listEvents;

	/*
	 * (non-Javadoc)
	 *
	 * @see Interface.IControllerFormGUI#showGUI()
	 */
	@Override
	public void showGUI() {
		if (this.registeredView == null) {
			this.registeredView = new ExitView(this);
		}

		else {
			if (this.registeredView.isShowed()) {
			} else {
				this.registeredView.setVisible(true);
			}
		}

	}

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	@Override
	public void actionPerformed(ActionEvent e) {

		if (e.getSource() instanceof NotificationToController) {
			NotificationToController btn = (NotificationToController) e
					.getSource();
			ExitView view = (ExitView) this.registeredView;

			switch (btn.getTypeButton()) {
			case NOBUTTON:
				view.setVisible(false);
				break;
			case YESBUTTON:
				this.registeredView.dispose();
				System.exit(0);
				break;
				default:
					break;

			}
		}
	}

	

}
